package game;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;

public class LoadGameLevelFromDisk 
	implements ActionListener
{
	@Override
	public void actionPerformed(ActionEvent e)
	{
//		File file;
//		try
//		{
//			file = new File("c:\\stuff\\temp\\game.txt");
//			JAXBContext jaxbContext = JAXBContext.newInstance(XmlGameLevel.class);
//			Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
//			// output pretty printed
//			jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
//	 
//			Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
//			XmlGameLevel gameLevel = (XmlGameLevel) jaxbUnmarshaller.unmarshal(file);
//			
//			Set<GameComponent> gameComponents = new HashSet<GameComponent>();
//			for (XmlGameComponent xmlGamecomponent : gameLevel.getGameComponents() )
//			{
//				gameComponents.add(new GameComponent(xmlGamecomponent.x(), xmlGamecomponent.y() ) );
//			}
//			Game.gameComponents(gameComponents);
//			
//			System.out.println(gameComponents);
//			
////			XmlGameLevel gameLevel = new XmlGameLevel(Game.gameComponents() );
////			jaxbMarshaller.marshal(gameLevel, file);
////			jaxbMarshaller.marshal(gameLevel, System.out);
//		}
//		catch(Exception exc)
//		{
//			System.out.println(exc);
//		}
		
		File file;
		try
		{
			file = new File("c:\\stuff\\temp\\game.txt");
			JAXBContext jaxbContext = JAXBContext.newInstance(GameLevelImpl.class);
			Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
			Game.gameLevel((GameLevelImpl)jaxbUnmarshaller.unmarshal(file));

		}
		catch(Exception exc)
		{
			System.out.println(exc);
		}

	}
}
